# Maintainer: David Runge <dvzrv@archlinux.org>

_name=aiosmtpd
pkgname=python-aiosmtpd
pkgver=1.4.4.post2
pkgrel=2
pkgdesc="An asyncio based SMTP server"
arch=(any)
url="https://github.com/aio-libs/aiosmtpd"
license=(Apache)
depends=(python-atpublic python-attrs python-typing-extensions)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(python-pytest python-pytest-mock)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha512sums=('b911e086f9fabd8b677d14cdc46573509377c491379148d8f8e76b96fdd509ba510550cb12b384dfc416759940494326ab6d719c859bce2048721d2d256d40fc')
b2sums=('7cb18a3e0bc95797ae8c516daeb2e8861b05deb9df6f0a9cb593425c872f4173d5976a4e587320825f7ba5f84dd3f1fa9ce5559babfced2d20003cc06c5f7d7d')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  pytest -vv --ignore=aiosmtpd/qa/
}

package() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  # remove unneeded stuff: https://github.com/aio-libs/aiosmtpd/issues/356
  rm -frv "$pkgdir/$_site_packages/$_name/"{docs,qa,tests}
}
